package com.example.shardingjdbcmysql.controller;


import com.example.shardingjdbcmysql.entity.Order;
import com.example.shardingjdbcmysql.mapper.OrderMapper;
import com.example.shardingjdbcmysql.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;
import java.util.List;

@RestController
public class OrderController {
    @Autowired
    OrderService orderService;
    @Autowired
    OrderMapper orderMapper;


    @GetMapping("/selectOrder")
    public Order select2(Integer id) {
        return  orderMapper.selectById(id);
    }


    @GetMapping("/select")
    public List<Order> select() {
        return orderService.getOrderList();
    }

    @GetMapping("/insert")
    public Boolean insert(Order order) {
        order.setIs_del(0);
        order.setCompany_id(0);
        order.setPosition_id(0);
        order.setPublish_user_id(0);
        order.setResume_type(0);
        order.setStatus("0");
        Timestamp time1 = new Timestamp(System.currentTimeMillis());
        order.setCreate_time(time1);
        order.setUpdate_time(time1);
        return orderService.save(order);
    }
}
